<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>用户注册</title>
		<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
		<!-- <script src="json.js" type="text/javascript"></script>   -->
		<script language="javascript">
			//查看用户名是否可用
			function validateName()
			{
				//请求的地址
				var url = 'validateNameAction';
				var username = $('input[name=userName]').val();
				$.post(url,{
					'userName': username
				},function(data){
					data = eval('('+data+')');
					if(data.tip == "用户名："+username+"已存在")
					{
						alert(data.tip);
					}
				},'json');
			}
			//验证邮箱格式是否正确
			function CheckMail(){
				var mail = $("mail").val();
				if(mail == ""){
					alert("请输入您的邮箱！");
					return false;
				}
				else{
					var reg = /^[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/;//邮箱验证正则表达式。 
					if(!reg.test($("#mail").val())){
						alert("您输入的邮箱格式不正确！请重新输入");
						return false;
					}
					else{
					return true;
					}
				}
			}
			//密码六位
			function Checkpasswd(){
				if($(this).is('#passwd')){
					if(this.value==""||this.value.length<6){
						var errMsg="请输入至少六位密码";
							alert(errMsg);
							$parent.append("<span class='formtips onError'>"+errorMsg+"</span>");
					}
				}
			}
		</script>
	
	</head>
  
  <body>
   <center>
		<h3>请输入注册信息</h3>
		<s:actionerror/>
		<span id="tip" style="color:red;font-weight:bold"></span>
			<form action="userAction" method="post"><br/>
				<table border="0">
				<tr>
					<td align="left"><s:textfield id="user" name="userName" label="用户名" onblur="validateName();"/></td>
					<td align="left"><s:password  id="passwd" name="userpass" label="密      码"/></td>
					<td align="left"><s:password  id="passwd1" name="userpass1" label="密      码"/></td>
					<td align="left"><s:textfield id="mail" name="useremail" label="电      邮" onblur="CheckMail();"/></td>
					<td align="left"><s:radio name="sex" list="%{#{'1':'男','0':'女'}}" value="1" label="性      别" /></td>
					<td align="left"><s:submit value="注册"/></td>
					<td>
						<div align="left">
							<a href="login.jsp">登陆</a>
						</div>
					</td>
				</tr>
				</table>
			</form>
		</center>
  </body>
</html>
